var of = require('OverFish'),
    crypto = require('crypto');

function User() {
}

exports.User = of.initModel(User, 'username', 'password', 'name', 'surname', 'email', 'last_login', 'roles');

User.prototype.validate = function() {
    this.validateRequired('username', 'Username is required.', false);
    this.validateRequired('password', 'Password is required.', false);
    this.validateRequired('email', 'Email is required.', false);
};

User.prototype.passwordHash = function() {
    return crypto.createHash('md5').update(this.password()).digest('hex');
};